<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module phonenumbers.phonenumbermatcher</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="phonenumbers.html"><font color="#ffffff">phonenumbers</font></a>.phonenumbermatcher</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="https://github.com/daviddrysdale/python-phonenumbers/blob/dev/python/phonenumbers/phonenumbermatcher.py">phonenumbers/phonenumbermatcher.py</a></font></td></tr></table>
    <p><tt>Functionality&nbsp;to&nbsp;match&nbsp;phone&nbsp;numbers&nbsp;in&nbsp;a&nbsp;piece&nbsp;of&nbsp;text</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="re.html">re</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
    
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonenumbermatcher.html#Leniency">Leniency</a>
</font></dt><dt><font face="helvetica, arial"><a href="phonenumbers.phonenumbermatcher.html#PhoneNumberMatcher">PhoneNumberMatcher</a>
</font></dt></dl>
</dd>
<dt><font face="helvetica, arial"><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>(<a href="builtins.html#object">builtins.object</a>)
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="phonenumbers.phonenumbermatcher.html#PhoneNumberMatch">PhoneNumberMatch</a>
</font></dt></dl>
</dd>
</dl>
 <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="Leniency">class <strong>Leniency</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt><a href="#Leniency">Leniency</a>&nbsp;when&nbsp;finding&nbsp;potential&nbsp;phone&nbsp;numbers&nbsp;in&nbsp;text&nbsp;segments.<br>
&nbsp;<br>
The&nbsp;levels&nbsp;here&nbsp;are&nbsp;ordered&nbsp;in&nbsp;increasing&nbsp;strictness.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>EXACT_GROUPING</strong> = 3</dl>

<dl><dt><strong>POSSIBLE</strong> = 0</dl>

<dl><dt><strong>STRICT_GROUPING</strong> = 2</dl>

<dl><dt><strong>VALID</strong> = 1</dl>

</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberMatch">class <strong>PhoneNumberMatch</strong></a>(<a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt><a href="#PhoneNumberMatch">PhoneNumberMatch</a>(start,&nbsp;raw_string,&nbsp;numobj)<br>
&nbsp;<br>
The&nbsp;immutable&nbsp;match&nbsp;of&nbsp;a&nbsp;phone&nbsp;number&nbsp;within&nbsp;a&nbsp;piece&nbsp;of&nbsp;text.<br>
&nbsp;<br>
Matches&nbsp;may&nbsp;be&nbsp;found&nbsp;using&nbsp;the&nbsp;find()&nbsp;method&nbsp;of&nbsp;<a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>.<br>
&nbsp;<br>
A&nbsp;match&nbsp;consists&nbsp;of&nbsp;the&nbsp;phone&nbsp;number&nbsp;(in&nbsp;.number)&nbsp;as&nbsp;well&nbsp;as&nbsp;the&nbsp;.start<br>
and&nbsp;.end&nbsp;offsets&nbsp;of&nbsp;the&nbsp;corresponding&nbsp;subsequence&nbsp;of&nbsp;the&nbsp;searched<br>
text.&nbsp;Use&nbsp;.raw_string&nbsp;to&nbsp;obtain&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;matched&nbsp;subsequence.<br>
&nbsp;<br>
The&nbsp;following&nbsp;annotated&nbsp;example&nbsp;clarifies&nbsp;the&nbsp;relationship&nbsp;between&nbsp;the<br>
searched&nbsp;text,&nbsp;the&nbsp;match&nbsp;offsets,&nbsp;and&nbsp;the&nbsp;parsed&nbsp;number:<br>
&nbsp;<br>
&gt;&gt;&gt;&nbsp;text&nbsp;=&nbsp;"Call&nbsp;me&nbsp;at&nbsp;+1&nbsp;425&nbsp;882-8080&nbsp;for&nbsp;details."<br>
&gt;&gt;&gt;&nbsp;country&nbsp;=&nbsp;"US"<br>
&gt;&gt;&gt;&nbsp;import&nbsp;phonenumbers<br>
&gt;&gt;&gt;&nbsp;matcher&nbsp;=&nbsp;phonenumbers.<a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>(text,&nbsp;country)<br>
&gt;&gt;&gt;&nbsp;matcher.has_next()<br>
True<br>
&gt;&gt;&gt;&nbsp;m&nbsp;=&nbsp;matcher.next()&nbsp;&nbsp;#&nbsp;Find&nbsp;the&nbsp;first&nbsp;phone&nbsp;number&nbsp;match<br>
&gt;&gt;&gt;&nbsp;m.raw_string&nbsp;#&nbsp;contains&nbsp;the&nbsp;phone&nbsp;number&nbsp;as&nbsp;it&nbsp;appears&nbsp;in&nbsp;the&nbsp;text.<br>
"+1&nbsp;425&nbsp;882-8080"<br>
&gt;&gt;&gt;&nbsp;(m.start,&nbsp;m.end)&nbsp;&nbsp;#&nbsp;define&nbsp;the&nbsp;range&nbsp;of&nbsp;the&nbsp;matched&nbsp;subsequence.<br>
(11,&nbsp;26)<br>
&gt;&gt;&gt;&nbsp;text[m.start,&nbsp;m.end]<br>
"+1&nbsp;425&nbsp;882-8080"<br>
&gt;&gt;&gt;&nbsp;phonenumberutil.parse("+1&nbsp;425&nbsp;882-8080",&nbsp;"US")&nbsp;==&nbsp;m.number<br>
True<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="phonenumbers.phonenumbermatcher.html#PhoneNumberMatch">PhoneNumberMatch</a></dd>
<dd><a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a></dd>
<dd><a href="builtins.html#object">builtins.object</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="PhoneNumberMatch-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Return&nbsp;self==value.</tt></dd></dl>

<dl><dt><a name="PhoneNumberMatch-__init__"><strong>__init__</strong></a>(self, start, raw_string, numobj)</dt><dd><tt>Initialize&nbsp;self.&nbsp;&nbsp;See&nbsp;help(type(self))&nbsp;for&nbsp;accurate&nbsp;signature.</tt></dd></dl>

<dl><dt><a name="PhoneNumberMatch-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return&nbsp;self!=value.</tt></dd></dl>

<dl><dt><a name="PhoneNumberMatch-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return&nbsp;repr(self).</tt></dd></dl>

<dl><dt><a name="PhoneNumberMatch-__unicode__"><strong>__unicode__</strong></a>(self)</dt></dl>

<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>__hash__</strong> = None</dl>

<hr>
Methods inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><a name="PhoneNumberMatch-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Return&nbsp;str(self).</tt></dd></dl>

<hr>
Data descriptors inherited from <a href="phonenumbers.util.html#UnicodeMixin">phonenumbers.util.UnicodeMixin</a>:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#000000" face="helvetica, arial"><a name="PhoneNumberMatcher">class <strong>PhoneNumberMatcher</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
    
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt><a href="#PhoneNumberMatcher">PhoneNumberMatcher</a>(text,&nbsp;region,&nbsp;leniency=1,&nbsp;max_tries=65535)<br>
&nbsp;<br>
A&nbsp;stateful&nbsp;class&nbsp;that&nbsp;finds&nbsp;and&nbsp;extracts&nbsp;telephone&nbsp;numbers&nbsp;from&nbsp;text.<br>
&nbsp;<br>
Vanity&nbsp;numbers&nbsp;(phone&nbsp;numbers&nbsp;using&nbsp;alphabetic&nbsp;digits&nbsp;such&nbsp;as&nbsp;'1-800-SIX-FLAGS'&nbsp;are<br>
not&nbsp;found.<br>
&nbsp;<br>
This&nbsp;class&nbsp;is&nbsp;not&nbsp;thread-safe.<br>&nbsp;</tt></td></tr>
<tr><td>&nbsp;</td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="PhoneNumberMatcher-__init__"><strong>__init__</strong></a>(self, text, region, leniency=1, max_tries=65535)</dt><dd><tt>Creates&nbsp;a&nbsp;new&nbsp;instance.<br>
&nbsp;<br>
Arguments:<br>
text&nbsp;--&nbsp;The&nbsp;character&nbsp;sequence&nbsp;that&nbsp;we&nbsp;will&nbsp;search,&nbsp;None&nbsp;for&nbsp;no&nbsp;text.<br>
country&nbsp;--&nbsp;The&nbsp;country&nbsp;to&nbsp;assume&nbsp;for&nbsp;phone&nbsp;numbers&nbsp;not&nbsp;written&nbsp;in<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;international&nbsp;format&nbsp;(with&nbsp;a&nbsp;leading&nbsp;plus,&nbsp;or&nbsp;with&nbsp;the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;international&nbsp;dialing&nbsp;prefix&nbsp;of&nbsp;the&nbsp;specified&nbsp;region).&nbsp;May&nbsp;be<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;None&nbsp;or&nbsp;"ZZ"&nbsp;if&nbsp;only&nbsp;numbers&nbsp;with&nbsp;a&nbsp;leading&nbsp;plus&nbsp;should&nbsp;be<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;considered.<br>
leniency&nbsp;--&nbsp;The&nbsp;leniency&nbsp;to&nbsp;use&nbsp;when&nbsp;evaluating&nbsp;candidate&nbsp;phone<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;numbers.<br>
max_tries&nbsp;--&nbsp;The&nbsp;maximum&nbsp;number&nbsp;of&nbsp;invalid&nbsp;numbers&nbsp;to&nbsp;try&nbsp;before<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;giving&nbsp;up&nbsp;on&nbsp;the&nbsp;text.&nbsp;&nbsp;This&nbsp;is&nbsp;to&nbsp;cover&nbsp;degenerate&nbsp;cases&nbsp;where<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;text&nbsp;has&nbsp;a&nbsp;lot&nbsp;of&nbsp;false&nbsp;positives&nbsp;in&nbsp;it.&nbsp;Must&nbsp;be&nbsp;&gt;=&nbsp;0.</tt></dd></dl>

<dl><dt><a name="PhoneNumberMatcher-__iter__"><strong>__iter__</strong></a>(self)</dt></dl>

<dl><dt><a name="PhoneNumberMatcher-has_next"><strong>has_next</strong></a>(self)</dt><dd><tt>Indicates&nbsp;whether&nbsp;there&nbsp;is&nbsp;another&nbsp;match&nbsp;available</tt></dd></dl>

<dl><dt><a name="PhoneNumberMatcher-next"><strong>next</strong></a>(self)</dt><dd><tt>Return&nbsp;the&nbsp;next&nbsp;match;&nbsp;raises&nbsp;Exception&nbsp;if&nbsp;no&nbsp;next&nbsp;match&nbsp;available</tt></dd></dl>

<hr>
Data descriptors defined here:<br>
<dl><dt><strong>__dict__</strong></dt>
<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
<dl><dt><strong>__weakref__</strong></dt>
<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
</dl>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>NON_DIGITS_PATTERN</strong> = re.compile('(?:\\D+)')<br>
<strong>U_DASH</strong> = '-'<br>
<strong>U_EMPTY_STRING</strong> = ''<br>
<strong>U_PERCENT</strong> = '%'<br>
<strong>U_SEMICOLON</strong> = ';'<br>
<strong>U_SLASH</strong> = '/'<br>
<strong>U_X_LOWER</strong> = 'x'<br>
<strong>U_X_UPPER</strong> = 'X'</td></tr></table>
</body></html>
